package org.examcity.domain.fixtures;

import org.examcity.domain.Objective;
import org.examcity.domain.Subject;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * Entity builder for {@link Objective}.
 * @author Antonio Gomes
 */
@Component
@Scope("prototype")
public class ObjectiveBuilder extends EntityBuilder<Objective> {

	public ObjectiveBuilder name(String name) {
		entity.setName(name);
		return this;
	}

	public ObjectiveBuilder description(String description) {
		entity.setDescription(description);
		return this;
	}

	public ObjectiveBuilder subject(Subject subject) {
		entity.setSubject(subject);
		return this;
	}

	@Override
	protected void beforeBuild() {
		Assert.notNull(entity.getSubject(), "'subject' is required");
		if (entity.getDescription() == null) {
			entity.setName("Description for " + entity.getName());
		}
	}

}
